#pragma once
#include "stdafx.h"

template <typename T>
class Composite
{
public:	// Composite pattern interface.

	void add(Composite<T>& val)
	{
		Compositer.push_back(&val);
	}

	bool remove(Composite<T>& val)
	{
		COMPOSITER_TYPE::iterator iter = 
			find(Compositer.begin(), Compositer.end(), &val);
		if (iter != Compositer.end())
		{
			Compositer.erase(iter);
			return true;
		}
		else
		{
			return false;
		}
	}

	void clear()
	{
		Compositer.clear();
	}

protected:
	typedef std::vector<T>	COMPOSITER_TYPE;
	COMPOSITER_TYPE			Compositer;


public:
	typedef typename COMPOSITER_TYPE::iterator iterator;

	iterator begin() { return Compositer.begin(); }
	iterator end() { return Compositer.end(); }
	T at(size_t i) { return Compositer.at(i); }

};



